<?php
if(!defined('FROM_INDEX'))exit('Invalid request');

require_once ROOT_PATH.'include/sql/function/tag.sql.php';
require_once ROOT_PATH.'service/base.service.php';

class TagService extends BaseService
{
	private $sqlFunc;
	
	function __construct()
	{
		$this->sqlFunc = new TagSqlFunc();
	}
	
	/**
	 *
	 * 热门话题
	 */
	function hot($request)
	{
		$result = $this->sqlFunc->hot($request);
		if (check_array($result))
		{
			foreach ($result as &$arr)
			{
				if (isset($arr['create_time']))
				{
					$arr['create_time'] = format_time($arr['create_time']);
				}
			}
		}
		return $result;
	}

	/**
	 *
	 * 搜索话题
	 * @param array $request
	 */
	function search($request)
	{
		$result = $this->sqlFunc->search($request);
		if (check_array($result))
		{
			foreach ($result as &$arr)
			{
				if (isset($arr['create_time']))
				{
					$arr['create_time'] = format_time($arr['create_time']);
				}
			}
		}
		
		return $result;
	}

	/**
	 * 获取话题详情
	 * @param string $id
	 */
	function get($id)
	{
		return $this->sqlFunc->get($id);
	}

	/**
	 *
	 * 新增话题
	 * @param array $request
	 */
	function add($request)
	{
		return $this->sqlFunc->add($request);
	}

	/**
	 *
	 * 更新话题信息
	 * @param unknown_type $request
	 */
	function update($request)
	{
		return $this->sqlFunc->update($request);
	}
	
	function update_story_count($tid)
	{
		return $this->sqlFunc->update_story_count($tid);
	}
	
	function delete($ids)
	{
		return $this->sqlFunc->delete($ids);
	}
}